<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>前言 | 协程</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="我们只听说过进程和线程，没有听说过协程，协程是个什么东西呢？我们的go语言，node.js语言的实现都使用到了协程，go的高效就不再细说了，那为什么使用了协程会让我们的后台程序变得高效呢？如果我们心里有这些疑问，那么请继续阅读本书和了解我们实现的开源库ntyco。">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="gitbook/style.css">
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="./chapter1/1_0.html" />
    
    

        
    </head>
    <body>
        
        
    <div class="book"
        data-level="0"
        data-chapter-title="前言"
        data-filepath="README.md"
        data-basepath="."
        data-revision="Sat Oct 13 2018 10:54:16 GMT+0800 (CST)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
                
                <li>
                    <a href="http://www.0voice.com" target="blank" class="custom-link">ntyTcp</a>
                </li>
            
            

            
            <li class="divider"></li>
            

            
    
        <li class="chapter active" data-level="0" data-path="index.html">
            
                
                    <a href="./index.html">
                
                        <i class="fa fa-check"></i>
                        
                        前言
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="chapter1/1_0.html">
            
                
                    <a href="./chapter1/1_0.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        协程的起源
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2" data-path="chapter2/2_0.html">
            
                
                    <a href="./chapter2/2_0.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        协程的案例
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3" data-path="chapter3/3_0.html">
            
                
                    <a href="./chapter3/3_0.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        协程的实现之工作原理
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4" data-path="chapter4/4_0.html">
            
                
                    <a href="./chapter4/4_0.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        协程的实现之原语操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5" data-path="chapter5/5_0.html">
            
                
                    <a href="./chapter5/5_0.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                        协程实现之切换
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6" data-path="chapter6/6_0.html">
            
                
                    <a href="./chapter6/6_0.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.</b>
                        
                        协程实现之定义
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7" data-path="chapter7/7_0.html">
            
                
                    <a href="./chapter7/7_0.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.</b>
                        
                        协程实现之调度器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8" data-path="chapter8/8_0.html">
            
                
                    <a href="./chapter8/8_0.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.</b>
                        
                        协程性能测试
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="9" data-path="chapter9/9_0.html">
            
                
                    <a href="./chapter9/9_0.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.</b>
                        
                        协程多核模式
                    </a>
            
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="./" >协程</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h2 id="&#x534F;&#x7A0B;">&#x534F;&#x7A0B;</h2>
<p>&#x6211;&#x4EEC;&#x53EA;&#x542C;&#x8BF4;&#x8FC7;&#x8FDB;&#x7A0B;&#x548C;&#x7EBF;&#x7A0B;&#xFF0C;&#x6CA1;&#x6709;&#x542C;&#x8BF4;&#x8FC7;&#x534F;&#x7A0B;&#xFF0C;&#x534F;&#x7A0B;&#x662F;&#x4E2A;&#x4EC0;&#x4E48;&#x4E1C;&#x897F;&#x5462;&#xFF1F;&#x6211;&#x4EEC;&#x7684;go&#x8BED;&#x8A00;&#xFF0C;node.js&#x8BED;&#x8A00;&#x7684;&#x5B9E;&#x73B0;&#x90FD;&#x4F7F;&#x7528;&#x5230;&#x4E86;&#x534F;&#x7A0B;&#xFF0C;go&#x7684;&#x9AD8;&#x6548;&#x5C31;&#x4E0D;&#x518D;&#x7EC6;&#x8BF4;&#x4E86;&#xFF0C;&#x90A3;&#x4E3A;&#x4EC0;&#x4E48;&#x4F7F;&#x7528;&#x4E86;&#x534F;&#x7A0B;&#x4F1A;&#x8BA9;&#x6211;&#x4EEC;&#x7684;&#x540E;&#x53F0;&#x7A0B;&#x5E8F;&#x53D8;&#x5F97;&#x9AD8;&#x6548;&#x5462;&#xFF1F;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x5FC3;&#x91CC;&#x6709;&#x8FD9;&#x4E9B;&#x7591;&#x95EE;&#xFF0C;&#x90A3;&#x4E48;&#x8BF7;&#x7EE7;&#x7EED;&#x9605;&#x8BFB;&#x672C;&#x4E66;&#x548C;&#x4E86;&#x89E3;&#x6211;&#x4EEC;&#x5B9E;&#x73B0;&#x7684;&#x5F00;&#x6E90;&#x5E93;ntyco&#x3002;</p>
<h2 id="&#x76EE;&#x5F55;">&#x76EE;&#x5F55;</h2>
<ul>
<li><a href="index.html">&#x524D;&#x8A00;</a></li>
<li><a href="chapter1/1_0.html">&#x534F;&#x7A0B;&#x7684;&#x8D77;&#x6E90;</a></li>
<li><a href="chapter2/2_0.html">&#x534F;&#x7A0B;&#x7684;&#x6848;&#x4F8B;</a></li>
<li><a href="chapter3/3_0.html">&#x534F;&#x7A0B;&#x7684;&#x5B9E;&#x73B0;&#x4E4B;&#x5DE5;&#x4F5C;&#x539F;&#x7406;</a><ul>
<li><a href="chapter3/3_0.html">&#x521B;&#x5EFA;&#x534F;&#x7A0B;</a></li>
<li><a href="chapter3/3_0.html">&#x5B9E;&#x73B0;IO&#x5F02;&#x6B65;&#x64CD;&#x4F5C;</a></li>
<li><a href="chapter3/3_0.html">&#x56DE;&#x8C03;&#x534F;&#x7A0B;&#x7684;&#x5B50;&#x64CD;&#x4F5C;</a></li>
</ul>
</li>
<li><a href="chapter4/4_0.html">&#x534F;&#x7A0B;&#x7684;&#x5B9E;&#x73B0;&#x4E4B;&#x539F;&#x8BED;&#x64CD;&#x4F5C;</a></li>
<li><a href="chapter5/5_0.html">&#x534F;&#x7A0B;&#x5B9E;&#x73B0;&#x4E4B;&#x5207;&#x6362;</a></li>
<li><a href="chapter6/6_0.html">&#x534F;&#x7A0B;&#x5B9E;&#x73B0;&#x4E4B;&#x5B9A;&#x4E49;</a><ul>
<li><a href="chapter6/6_0.html">&#x8FD0;&#x884C;&#x4F53;&#x9AD8;&#x6548;&#x5207;&#x6362;</a></li>
<li><a href="chapter6/6_0.html">&#x8C03;&#x5EA6;&#x5668;&#x4E0E;&#x534F;&#x7A0B;&#x7684;&#x529F;&#x80FD;&#x754C;&#x9650;</a></li>
</ul>
</li>
<li><a href="chapter7/7_0.html">&#x534F;&#x7A0B;&#x5B9E;&#x73B0;&#x4E4B;&#x8C03;&#x5EA6;&#x5668;</a><ul>
<li><a href="chapter7/7_0.html">&#x751F;&#x4EA7;&#x8005;&#x6D88;&#x8D39;&#x8005;&#x6A21;&#x5F0F;</a></li>
<li><a href="chapter7/7_0.html">&#x591A;&#x72B6;&#x6001;&#x4E0B;&#x8FD0;&#x884C;</a></li>
</ul>
</li>
<li><a href="chapter8/8_0.html">&#x534F;&#x7A0B;&#x6027;&#x80FD;&#x6D4B;&#x8BD5;</a></li>
<li><a href="chapter9/9_0.html">&#x534F;&#x7A0B;&#x591A;&#x6838;&#x6A21;&#x5F0F;</a></li>
</ul>
<h2 id="&#x9E23;&#x8C22;">&#x9E23;&#x8C22;</h2>
<p>&#x5728;&#x6B64;&#x8981;&#x7279;&#x522B;&#x611F;&#x8C22;&#x6211;&#x4EEC;&#x7684;&#x56E2;&#x961F;&#x7684;&#x6BCF;&#x4E00;&#x4F4D;&#x6210;&#x5458;&#x7684;&#x52AA;&#x529B;&#xFF0C;&#x4E5F;&#x7279;&#x522B;&#x611F;&#x8C22;&#x80CC;&#x540E;&#x9ED8;&#x9ED8;&#x652F;&#x6301;&#x6211;&#x4EEC;&#x7684;&#x5BB6;&#x4EBA;&#x4EEC;&#x3002;&#x5982;&#x679C;&#x4F60;&#x6709;&#x4EFB;&#x4F55;&#x7591;&#x95EE;&#xFF0C;&#x6216;&#x8005;&#x60F3;&#x548C;&#x6211;&#x4EEC;&#x63A2;&#x8BA8;&#x6280;&#x672F;&#x8BF7;&#x8054;&#x7CFB;&#x6211;&#x4EEC;&#xFF1A;</p>
<p>email: 1989wangbojing@163.com<br>email: lizhiyong4360@gmail.com<br>email: 592407834@qq.com<br>qq&#x7FA4;: 829348971</p>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        
        <a href="./chapter1/1_0.html" class="navigation navigation-next navigation-unique" aria-label="Next page: 协程的起源"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="gitbook/app.js"></script>

    
    <script src="gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-livereload/plugin.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"theme-default":{"showLevel":false},"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"livereload":{}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
